package com.gomyb.common.page;

import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

/**
 * @author <a href="mailto:HelloHeSir@gmail.com">HeC</a>
 * @date 2018/12/11 11:05
 * 通用查询
 * field 为实体字段名称
 * <p>
 * filter规则
 * COLUMN           =   默认全词匹配
 * COLUMN_EQ        =
 * COLUMN_NO_EQ     !=
 * COLUMN_LIKE      like value
 */
public class QueryFilter {

    @Getter
    @Setter
    private Map<String, String> filter = new HashMap<>(8);

    public QueryFilter eq(String field, Object value) {
        filter.put(field + "_EQ", value.toString());
        return this;
    }

    public QueryFilter noEq(String field, String value) {
        filter.put(field + "_NO_EQ", value);
        return this;
    }

    public QueryFilter like(String field, String value) {
        filter.put(field + "_LIKE", value);
        return this;
    }

}